package com.aijk;

import com.aijk.config.druid.DruidProperties;
import com.aijk.config.PublicConfig;
import com.aijk.demo.EchoServiceApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;

/**
 * User: chendw
 * Date: 2016/7/28 10:07
 * To change this template use File | Settings | File Templates.
 */
@SpringBootApplication
//@MapperScan(basePackages = "com.aijk.mapper")
@EnableConfigurationProperties({DruidProperties.class})
public class Application {
    private static final Logger logger = LoggerFactory.getLogger(Application.class);

    public static void main(String[] args) {

        ApplicationContext ctx = SpringApplication.run(Application.class, args);
        String[] activeProfiles = ctx.getEnvironment().getActiveProfiles();
        for (String profile : activeProfiles) {
            logger.warn("Spring Boot 使用profile为:{}", profile);
        }

        logger.info("测试共用变量:{}", PublicConfig.welcome);
        logger.info("测试共用环境变量:{}", PublicConfig.env);

        EchoServiceApi bean = ctx.getBean(EchoServiceApi.class);
        System.out.println(bean.echo("abccc"));
    }
}
